<!doctype html>
<html>

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
  <link rel="stylesheet" href="../../static/BOSGeo/BOSGeo.css" />
  <title>添加html</title>
  <style>
    html {
      font-size: 12px;
    }

    html,
    body,
    #mapContainer {
      height: 100%;
      width: 100%;
      padding: 0;
      margin: 0;
    }

  </style>
</head>

<body>
  <div id="mapContainer"></div>
  <script src="../../static/BOSGeo/BOSGeo.js"></script>
  <script>
    var map = new BOSGeo.Map('mapContainer', {
    mapType: BOSGeo.TDT_IMAGERY
    });

    var layers = map.layers;
    var htmlCollection = new BOSGeo.LayerCollection({
    name: 'html集合',
    type: 'html'
    });
    layers.add(htmlCollection);
    let html = new BOSGeo.HtmlLayer({
        name: '标牌',
        position: [121.46301, 31.16747, 0],
        html: '<div style="padding: 4px 8px; background: darkcyan; color: #ffffff;">标牌示例</div>',
        onClick: layer => {
            layer.zoomTo();
        }
    });
    htmlCollection.add(html);
    // layers.remove(htmlCollection); // 移除html
    
    map.viewFix(121.4658, 31.16493, 1000, {
    heading: 283.40944,
    pitch: -84.58174,
    roll: 178.23488
    })
  </script>
</body>

</html>